﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x0200014B RID: 331
	[Serializable]
	public class Grounding
	{
		// Token: 0x17000036 RID: 54
		// (get) Token: 0x06000532 RID: 1330 RVA: 0x00017BA8 File Offset: 0x00015FA8
		// (set) Token: 0x06000533 RID: 1331 RVA: 0x00017BB0 File Offset: 0x00015FB0
		public Grounding.Leg[] legs { get; private set; }

		// Token: 0x17000037 RID: 55
		// (get) Token: 0x06000534 RID: 1332 RVA: 0x00017BB9 File Offset: 0x00015FB9
		// (set) Token: 0x06000535 RID: 1333 RVA: 0x00017BC1 File Offset: 0x00015FC1
		public Grounding.Pelvis pelvis { get; private set; }

		// Token: 0x17000038 RID: 56
		// (get) Token: 0x06000536 RID: 1334 RVA: 0x00017BCA File Offset: 0x00015FCA
		// (set) Token: 0x06000537 RID: 1335 RVA: 0x00017BD2 File Offset: 0x00015FD2
		public bool isGrounded { get; private set; }

		// Token: 0x17000039 RID: 57
		// (get) Token: 0x06000538 RID: 1336 RVA: 0x00017BDB File Offset: 0x00015FDB
		// (set) Token: 0x06000539 RID: 1337 RVA: 0x00017BE3 File Offset: 0x00015FE3
		public Transform root { get; private set; }

		// Token: 0x1700003A RID: 58
		// (get) Token: 0x0600053A RID: 1338 RVA: 0x00017BEC File Offset: 0x00015FEC
		// (set) Token: 0x0600053B RID: 1339 RVA: 0x00017BF4 File Offset: 0x00015FF4
		public RaycastHit rootHit { get; private set; }

		// Token: 0x1700003B RID: 59
		// (get) Token: 0x0600053C RID: 1340 RVA: 0x00017C00 File Offset: 0x00016000
		public bool rootGrounded
		{
			get
			{
				return this.rootHit.distance < this.maxStep * 2f;
			}
		}

		// Token: 0x0600053D RID: 1341 RVA: 0x00017C2C File Offset: 0x0001602C
		public RaycastHit GetRootHit(float maxDistanceMlp = 10f)
		{
			RaycastHit result = default(RaycastHit);
			Vector3 up = this.up;
			Vector3 a = Vector3.zero;
			foreach (Grounding.Leg leg in this.legs)
			{
				a += leg.transform.position;
			}
			a /= (float)this.legs.Length;
			result.point = a - up * this.maxStep * 10f;
			float num = maxDistanceMlp + 1f;
			result.distance = this.maxStep * num;
			if (this.maxStep <= 0f)
			{
				return result;
			}
			if (this.quality != Grounding.Quality.Best)
			{
				Physics.Raycast(a + up * this.maxStep, -up, out result, this.maxStep * num, this.layers);
			}
			else
			{
				Physics.SphereCast(a + up * this.maxStep, this.rootSphereCastRadius, -this.up, out result, this.maxStep * num, this.layers);
			}
			return result;
		}

		// Token: 0x0600053E RID: 1342 RVA: 0x00017D6C File Offset: 0x0001616C
		public bool IsValid(ref string errorMessage)
		{
			if (this.root == null)
			{
				errorMessage = "Root transform is null. Can't initiate Grounding.";
				return false;
			}
			if (this.legs == null)
			{
				errorMessage = "Grounding legs is null. Can't initiate Grounding.";
				return false;
			}
			if (this.pelvis == null)
			{
				errorMessage = "Grounding pelvis is null. Can't initiate Grounding.";
				return false;
			}
			if (this.legs.Length == 0)
			{
				errorMessage = "Grounding has 0 legs. Can't initiate Grounding.";
				return false;
			}
			return true;
		}

		// Token: 0x0600053F RID: 1343 RVA: 0x00017DD4 File Offset: 0x000161D4
		public void Initiate(Transform root, Transform[] feet)
		{
			this.root = root;
			this.initiated = false;
			this.rootHit = default(RaycastHit);
			if (this.legs == null)
			{
				this.legs = new Grounding.Leg[feet.Length];
			}
			if (this.legs.Length != feet.Length)
			{
				this.legs = new Grounding.Leg[feet.Length];
			}
			for (int i = 0; i < feet.Length; i++)
			{
				if (this.legs[i] == null)
				{
					this.legs[i] = new Grounding.Leg();
				}
			}
			if (this.pelvis == null)
			{
				this.pelvis = new Grounding.Pelvis();
			}
			string empty = string.Empty;
			if (!this.IsValid(ref empty))
			{
				Warning.Log(empty, root, false);
				return;
			}
			if (Application.isPlaying)
			{
				for (int j = 0; j < feet.Length; j++)
				{
					this.legs[j].Initiate(this, feet[j]);
				}
				this.pelvis.Initiate(this);
				this.initiated = true;
			}
		}

		// Token: 0x06000540 RID: 1344 RVA: 0x00017ED8 File Offset: 0x000162D8
		public void Update()
		{
			if (!this.initiated)
			{
				return;
			}
			if (this.layers == 0)
			{
				this.LogWarning("Grounding layers are set to nothing. Please add a ground layer.");
			}
			this.maxStep = Mathf.Clamp(this.maxStep, 0f, this.maxStep);
			this.footRadius = Mathf.Clamp(this.footRadius, 0.0001f, this.maxStep);
			this.pelvisDamper = Mathf.Clamp(this.pelvisDamper, 0f, 1f);
			this.rootSphereCastRadius = Mathf.Clamp(this.rootSphereCastRadius, 0.0001f, this.rootSphereCastRadius);
			this.maxFootRotationAngle = Mathf.Clamp(this.maxFootRotationAngle, 0f, 90f);
			this.prediction = Mathf.Clamp(this.prediction, 0f, this.prediction);
			this.footSpeed = Mathf.Clamp(this.footSpeed, 0f, this.footSpeed);
			this.rootHit = this.GetRootHit(10f);
			float num = float.NegativeInfinity;
			float num2 = float.PositiveInfinity;
			this.isGrounded = false;
			foreach (Grounding.Leg leg in this.legs)
			{
				leg.Process();
				if (leg.IKOffset > num)
				{
					num = leg.IKOffset;
				}
				if (leg.IKOffset < num2)
				{
					num2 = leg.IKOffset;
				}
				if (leg.isGrounded)
				{
					this.isGrounded = true;
				}
			}
			this.pelvis.Process(-num * this.lowerPelvisWeight, -num2 * this.liftPelvisWeight, this.isGrounded);
		}

		// Token: 0x06000541 RID: 1345 RVA: 0x00018078 File Offset: 0x00016478
		public Vector3 GetLegsPlaneNormal()
		{
			if (!this.initiated)
			{
				return Vector3.up;
			}
			Vector3 up = this.up;
			Vector3 vector = up;
			for (int i = 0; i < this.legs.Length; i++)
			{
				Vector3 vector2 = this.legs[i].IKPosition - this.root.position;
				Vector3 vector3 = up;
				Vector3 fromDirection = vector2;
				Vector3.OrthoNormalize(ref vector3, ref fromDirection);
				Quaternion rotation = Quaternion.FromToRotation(fromDirection, vector2);
				vector = rotation * vector;
			}
			return vector;
		}

		// Token: 0x06000542 RID: 1346 RVA: 0x000180FC File Offset: 0x000164FC
		public void Reset()
		{
			if (!Application.isPlaying)
			{
				return;
			}
			this.pelvis.Reset();
			foreach (Grounding.Leg leg in this.legs)
			{
				leg.Reset();
			}
		}

		// Token: 0x06000543 RID: 1347 RVA: 0x00018144 File Offset: 0x00016544
		public void LogWarning(string message)
		{
			Warning.Log(message, this.root, false);
		}

		// Token: 0x1700003C RID: 60
		// (get) Token: 0x06000544 RID: 1348 RVA: 0x00018153 File Offset: 0x00016553
		public Vector3 up
		{
			get
			{
				return (!this.useRootRotation) ? Vector3.up : this.root.up;
			}
		}

		// Token: 0x06000545 RID: 1349 RVA: 0x00018178 File Offset: 0x00016578
		public float GetVerticalOffset(Vector3 p1, Vector3 p2)
		{
			if (this.useRootRotation)
			{
				return (Quaternion.Inverse(this.root.rotation) * (p1 - p2)).y;
			}
			return p1.y - p2.y;
		}

		// Token: 0x06000546 RID: 1350 RVA: 0x000181C4 File Offset: 0x000165C4
		public Vector3 Flatten(Vector3 v)
		{
			if (this.useRootRotation)
			{
				Vector3 onNormal = v;
				Vector3 up = this.root.up;
				Vector3.OrthoNormalize(ref up, ref onNormal);
				return Vector3.Project(v, onNormal);
			}
			v.y = 0f;
			return v;
		}

		// Token: 0x1700003D RID: 61
		// (get) Token: 0x06000547 RID: 1351 RVA: 0x00018208 File Offset: 0x00016608
		private bool useRootRotation
		{
			get
			{
				return this.rotateSolver && !(this.root.up == Vector3.up);
			}
		}

		// Token: 0x0400026C RID: 620
		[Tooltip("Layers to ground the character to. Make sure to exclude the layer of the character controller.")]
		public LayerMask layers;

		// Token: 0x0400026D RID: 621
		[Tooltip("Max step height. Maximum vertical distance of Grounding from the root of the character.")]
		public float maxStep = 0.5f;

		// Token: 0x0400026E RID: 622
		[Tooltip("The height offset of the root.")]
		public float heightOffset;

		// Token: 0x0400026F RID: 623
		[Tooltip("The speed of moving the feet up/down.")]
		public float footSpeed = 2.5f;

		// Token: 0x04000270 RID: 624
		[Tooltip("CapsuleCast radius. Should match approximately with the size of the feet.")]
		public float footRadius = 0.15f;

		// Token: 0x04000271 RID: 625
		[Tooltip("Amount of velocity based prediction of the foot positions.")]
		public float prediction = 0.05f;

		// Token: 0x04000272 RID: 626
		[Tooltip("Weight of rotating the feet to the ground normal offset.")]
		[Range(0f, 1f)]
		public float footRotationWeight = 1f;

		// Token: 0x04000273 RID: 627
		[Tooltip("Speed of slerping the feet to their grounded rotations.")]
		public float footRotationSpeed = 7f;

		// Token: 0x04000274 RID: 628
		[Tooltip("Max Foot Rotation Angle. Max angular offset from the foot's rotation.")]
		[Range(0f, 90f)]
		public float maxFootRotationAngle = 45f;

		// Token: 0x04000275 RID: 629
		[Tooltip("If true, solver will rotate with the character root so the character can be grounded for example to spherical planets. For performance reasons leave this off unless needed.")]
		public bool rotateSolver;

		// Token: 0x04000276 RID: 630
		[Tooltip("The speed of moving the character up/down.")]
		public float pelvisSpeed = 5f;

		// Token: 0x04000277 RID: 631
		[Tooltip("Used for smoothing out vertical pelvis movement (range 0 - 1).")]
		[Range(0f, 1f)]
		public float pelvisDamper;

		// Token: 0x04000278 RID: 632
		[Tooltip("The weight of lowering the pelvis to the lowest foot.")]
		public float lowerPelvisWeight = 1f;

		// Token: 0x04000279 RID: 633
		[Tooltip("The weight of lifting the pelvis to the highest foot. This is useful when you don't want the feet to go too high relative to the body when crouching.")]
		public float liftPelvisWeight;

		// Token: 0x0400027A RID: 634
		[Tooltip("The radius of the spherecast from the root that determines whether the character root is grounded.")]
		public float rootSphereCastRadius = 0.1f;

		// Token: 0x0400027B RID: 635
		[Tooltip("The raycasting quality. Fastest is a single raycast per foot, Simple is three raycasts, Best is one raycast and a capsule cast per foot.")]
		public Grounding.Quality quality = Grounding.Quality.Best;

		// Token: 0x04000281 RID: 641
		private bool initiated;

		// Token: 0x0200014C RID: 332
		[Serializable]
		public enum Quality
		{
			// Token: 0x04000283 RID: 643
			Fastest,
			// Token: 0x04000284 RID: 644
			Simple,
			// Token: 0x04000285 RID: 645
			Best
		}

		// Token: 0x0200014D RID: 333
		public class Leg
		{
			// Token: 0x1700003E RID: 62
			// (get) Token: 0x06000549 RID: 1353 RVA: 0x00018247 File Offset: 0x00016647
			// (set) Token: 0x0600054A RID: 1354 RVA: 0x0001824F File Offset: 0x0001664F
			public bool isGrounded { get; private set; }

			// Token: 0x1700003F RID: 63
			// (get) Token: 0x0600054B RID: 1355 RVA: 0x00018258 File Offset: 0x00016658
			// (set) Token: 0x0600054C RID: 1356 RVA: 0x00018260 File Offset: 0x00016660
			public Vector3 IKPosition { get; private set; }

			// Token: 0x17000040 RID: 64
			// (get) Token: 0x0600054D RID: 1357 RVA: 0x00018269 File Offset: 0x00016669
			// (set) Token: 0x0600054E RID: 1358 RVA: 0x00018271 File Offset: 0x00016671
			public Quaternion rotationOffset { get; private set; }

			// Token: 0x17000041 RID: 65
			// (get) Token: 0x0600054F RID: 1359 RVA: 0x0001827A File Offset: 0x0001667A
			// (set) Token: 0x06000550 RID: 1360 RVA: 0x00018282 File Offset: 0x00016682
			public bool initiated { get; private set; }

			// Token: 0x17000042 RID: 66
			// (get) Token: 0x06000551 RID: 1361 RVA: 0x0001828B File Offset: 0x0001668B
			// (set) Token: 0x06000552 RID: 1362 RVA: 0x00018293 File Offset: 0x00016693
			public float heightFromGround { get; private set; }

			// Token: 0x17000043 RID: 67
			// (get) Token: 0x06000553 RID: 1363 RVA: 0x0001829C File Offset: 0x0001669C
			// (set) Token: 0x06000554 RID: 1364 RVA: 0x000182A4 File Offset: 0x000166A4
			public Vector3 velocity { get; private set; }

			// Token: 0x17000044 RID: 68
			// (get) Token: 0x06000555 RID: 1365 RVA: 0x000182AD File Offset: 0x000166AD
			// (set) Token: 0x06000556 RID: 1366 RVA: 0x000182B5 File Offset: 0x000166B5
			public Transform transform { get; private set; }

			// Token: 0x17000045 RID: 69
			// (get) Token: 0x06000557 RID: 1367 RVA: 0x000182BE File Offset: 0x000166BE
			// (set) Token: 0x06000558 RID: 1368 RVA: 0x000182C6 File Offset: 0x000166C6
			public float IKOffset { get; private set; }

			// Token: 0x06000559 RID: 1369 RVA: 0x000182CF File Offset: 0x000166CF
			public void Initiate(Grounding grounding, Transform transform)
			{
				this.initiated = false;
				this.grounding = grounding;
				this.transform = transform;
				this.up = Vector3.up;
				this.IKPosition = transform.position;
				this.initiated = true;
				this.OnEnable();
			}

			// Token: 0x0600055A RID: 1370 RVA: 0x0001830A File Offset: 0x0001670A
			public void OnEnable()
			{
				if (!this.initiated)
				{
					return;
				}
				this.lastPosition = this.transform.position;
				this.lastTime = Time.deltaTime;
			}

			// Token: 0x0600055B RID: 1371 RVA: 0x00018334 File Offset: 0x00016734
			public void Reset()
			{
				this.lastPosition = this.transform.position;
				this.lastTime = Time.deltaTime;
				this.IKOffset = 0f;
				this.IKPosition = this.transform.position;
				this.rotationOffset = Quaternion.identity;
			}

			// Token: 0x0600055C RID: 1372 RVA: 0x00018384 File Offset: 0x00016784
			public void Process()
			{
				if (!this.initiated)
				{
					return;
				}
				if (this.grounding.maxStep <= 0f)
				{
					return;
				}
				this.deltaTime = Time.time - this.lastTime;
				this.lastTime = Time.time;
				if (this.deltaTime == 0f)
				{
					return;
				}
				this.up = this.grounding.up;
				this.heightFromGround = float.PositiveInfinity;
				this.velocity = (this.transform.position - this.lastPosition) / this.deltaTime;
				this.velocity = this.grounding.Flatten(this.velocity);
				this.lastPosition = this.transform.position;
				Vector3 vector = this.velocity * this.grounding.prediction;
				if (this.grounding.footRadius <= 0f)
				{
					this.grounding.quality = Grounding.Quality.Fastest;
				}
				Grounding.Quality quality = this.grounding.quality;
				if (quality != Grounding.Quality.Fastest)
				{
					if (quality != Grounding.Quality.Simple)
					{
						if (quality == Grounding.Quality.Best)
						{
							this.heelHit = this.GetRaycastHit(Vector3.zero);
							RaycastHit capsuleHit = this.GetCapsuleHit(vector);
							this.SetFootToPlane(capsuleHit.normal, capsuleHit.point, this.heelHit.point);
						}
					}
					else
					{
						this.heelHit = this.GetRaycastHit(Vector3.zero);
						RaycastHit raycastHit = this.GetRaycastHit(this.grounding.root.forward * this.grounding.footRadius + vector);
						RaycastHit raycastHit2 = this.GetRaycastHit(this.grounding.root.right * this.grounding.footRadius * 0.5f);
						Vector3 vector2 = Vector3.Cross(raycastHit.point - this.heelHit.point, raycastHit2.point - this.heelHit.point).normalized;
						if (Vector3.Dot(vector2, this.up) < 0f)
						{
							vector2 = -vector2;
						}
						this.SetFootToPlane(vector2, this.heelHit.point, this.heelHit.point);
					}
				}
				else
				{
					RaycastHit raycastHit3 = this.GetRaycastHit(vector);
					this.SetFootToPoint(raycastHit3.normal, raycastHit3.point);
				}
				this.isGrounded = (this.heightFromGround < this.grounding.maxStep);
				float num = this.stepHeightFromGround;
				if (!this.grounding.rootGrounded)
				{
					num = 0f;
				}
				this.IKOffset = Interp.LerpValue(this.IKOffset, num, this.grounding.footSpeed, this.grounding.footSpeed);
				this.IKOffset = Mathf.Lerp(this.IKOffset, num, this.deltaTime * this.grounding.footSpeed);
				float verticalOffset = this.grounding.GetVerticalOffset(this.transform.position, this.grounding.root.position);
				float num2 = Mathf.Clamp(this.grounding.maxStep - verticalOffset, 0f, this.grounding.maxStep);
				this.IKOffset = Mathf.Clamp(this.IKOffset, -num2, this.IKOffset);
				this.RotateFoot();
				this.IKPosition = this.transform.position - this.up * this.IKOffset;
				float footRotationWeight = this.grounding.footRotationWeight;
				this.rotationOffset = ((footRotationWeight < 1f) ? Quaternion.Slerp(Quaternion.identity, this.r, footRotationWeight) : this.r);
			}

			// Token: 0x17000046 RID: 70
			// (get) Token: 0x0600055D RID: 1373 RVA: 0x0001874F File Offset: 0x00016B4F
			public float stepHeightFromGround
			{
				get
				{
					return Mathf.Clamp(this.heightFromGround, -this.grounding.maxStep, this.grounding.maxStep);
				}
			}

			// Token: 0x0600055E RID: 1374 RVA: 0x00018774 File Offset: 0x00016B74
			private RaycastHit GetCapsuleHit(Vector3 offsetFromHeel)
			{
				RaycastHit result = default(RaycastHit);
				Vector3 a = this.transform.position + this.grounding.root.forward * this.grounding.footRadius;
				result.point = a - this.up * this.grounding.maxStep * 2f;
				result.normal = this.up;
				Vector3 vector = a + this.grounding.maxStep * this.up;
				Vector3 point = vector + offsetFromHeel;
				Physics.CapsuleCast(vector, point, this.grounding.footRadius, -this.up, out result, this.grounding.maxStep * 3f, this.grounding.layers);
				return result;
			}

			// Token: 0x0600055F RID: 1375 RVA: 0x0001885C File Offset: 0x00016C5C
			private RaycastHit GetRaycastHit(Vector3 offsetFromHeel)
			{
				RaycastHit result = default(RaycastHit);
				Vector3 a = this.transform.position + offsetFromHeel;
				result.point = a - this.up * this.grounding.maxStep * 2f;
				result.normal = this.up;
				if (this.grounding.maxStep <= 0f)
				{
					return result;
				}
				Physics.Raycast(a + this.grounding.maxStep * this.up, -this.up, out result, this.grounding.maxStep * 3f, this.grounding.layers);
				return result;
			}

			// Token: 0x06000560 RID: 1376 RVA: 0x00018925 File Offset: 0x00016D25
			private Vector3 RotateNormal(Vector3 normal)
			{
				if (this.grounding.quality == Grounding.Quality.Best)
				{
					return normal;
				}
				return Vector3.RotateTowards(this.up, normal, this.grounding.maxFootRotationAngle * 0.017453292f, this.deltaTime);
			}

			// Token: 0x06000561 RID: 1377 RVA: 0x0001895D File Offset: 0x00016D5D
			private void SetFootToPoint(Vector3 normal, Vector3 point)
			{
				this.toHitNormal = Quaternion.FromToRotation(this.up, this.RotateNormal(normal));
				this.heightFromGround = this.GetHeightFromGround(point);
			}

			// Token: 0x06000562 RID: 1378 RVA: 0x00018984 File Offset: 0x00016D84
			private void SetFootToPlane(Vector3 planeNormal, Vector3 planePoint, Vector3 heelHitPoint)
			{
				planeNormal = this.RotateNormal(planeNormal);
				this.toHitNormal = Quaternion.FromToRotation(this.up, planeNormal);
				Vector3 hitPoint = V3Tools.LineToPlane(this.transform.position + this.up * this.grounding.maxStep, -this.up, planeNormal, planePoint);
				this.heightFromGround = this.GetHeightFromGround(hitPoint);
				float heightFromGround = this.GetHeightFromGround(heelHitPoint);
				this.heightFromGround = Mathf.Clamp(this.heightFromGround, float.NegativeInfinity, heightFromGround);
			}

			// Token: 0x06000563 RID: 1379 RVA: 0x00018A11 File Offset: 0x00016E11
			private float GetHeightFromGround(Vector3 hitPoint)
			{
				return this.grounding.GetVerticalOffset(this.transform.position, hitPoint) - this.rootYOffset;
			}

			// Token: 0x06000564 RID: 1380 RVA: 0x00018A34 File Offset: 0x00016E34
			private void RotateFoot()
			{
				Quaternion rotationOffsetTarget = this.GetRotationOffsetTarget();
				this.r = Quaternion.Slerp(this.r, rotationOffsetTarget, this.deltaTime * this.grounding.footRotationSpeed);
			}

			// Token: 0x06000565 RID: 1381 RVA: 0x00018A6C File Offset: 0x00016E6C
			private Quaternion GetRotationOffsetTarget()
			{
				if (this.grounding.maxFootRotationAngle <= 0f)
				{
					return Quaternion.identity;
				}
				if (this.grounding.maxFootRotationAngle >= 180f)
				{
					return this.toHitNormal;
				}
				return Quaternion.RotateTowards(Quaternion.identity, this.toHitNormal, this.grounding.maxFootRotationAngle);
			}

			// Token: 0x17000047 RID: 71
			// (get) Token: 0x06000566 RID: 1382 RVA: 0x00018ACC File Offset: 0x00016ECC
			private float rootYOffset
			{
				get
				{
					return this.grounding.GetVerticalOffset(this.transform.position, this.grounding.root.position - this.up * this.grounding.heightOffset);
				}
			}

			// Token: 0x0400028E RID: 654
			private Grounding grounding;

			// Token: 0x0400028F RID: 655
			private float lastTime;

			// Token: 0x04000290 RID: 656
			private float deltaTime;

			// Token: 0x04000291 RID: 657
			private Vector3 lastPosition;

			// Token: 0x04000292 RID: 658
			private Quaternion toHitNormal;

			// Token: 0x04000293 RID: 659
			private Quaternion r;

			// Token: 0x04000294 RID: 660
			private RaycastHit heelHit;

			// Token: 0x04000295 RID: 661
			private Vector3 up = Vector3.up;
		}

		// Token: 0x0200014E RID: 334
		public class Pelvis
		{
			// Token: 0x17000048 RID: 72
			// (get) Token: 0x06000568 RID: 1384 RVA: 0x00018B22 File Offset: 0x00016F22
			// (set) Token: 0x06000569 RID: 1385 RVA: 0x00018B2A File Offset: 0x00016F2A
			public Vector3 IKOffset { get; private set; }

			// Token: 0x17000049 RID: 73
			// (get) Token: 0x0600056A RID: 1386 RVA: 0x00018B33 File Offset: 0x00016F33
			// (set) Token: 0x0600056B RID: 1387 RVA: 0x00018B3B File Offset: 0x00016F3B
			public float heightOffset { get; private set; }

			// Token: 0x0600056C RID: 1388 RVA: 0x00018B44 File Offset: 0x00016F44
			public void Initiate(Grounding grounding)
			{
				this.grounding = grounding;
				this.initiated = true;
				this.OnEnable();
			}

			// Token: 0x0600056D RID: 1389 RVA: 0x00018B5A File Offset: 0x00016F5A
			public void Reset()
			{
				this.lastRootPosition = this.grounding.root.transform.position;
				this.lastTime = Time.deltaTime;
				this.IKOffset = Vector3.zero;
				this.heightOffset = 0f;
			}

			// Token: 0x0600056E RID: 1390 RVA: 0x00018B98 File Offset: 0x00016F98
			public void OnEnable()
			{
				if (!this.initiated)
				{
					return;
				}
				this.lastRootPosition = this.grounding.root.transform.position;
				this.lastTime = Time.time;
			}

			// Token: 0x0600056F RID: 1391 RVA: 0x00018BCC File Offset: 0x00016FCC
			public void Process(float lowestOffset, float highestOffset, bool isGrounded)
			{
				if (!this.initiated)
				{
					return;
				}
				float num = Time.time - this.lastTime;
				this.lastTime = Time.time;
				if (num <= 0f)
				{
					return;
				}
				float b = lowestOffset + highestOffset;
				if (!this.grounding.rootGrounded)
				{
					b = 0f;
				}
				this.heightOffset = Mathf.Lerp(this.heightOffset, b, num * this.grounding.pelvisSpeed);
				Vector3 p = this.grounding.root.position - this.lastRootPosition;
				this.lastRootPosition = this.grounding.root.position;
				this.damperF = Interp.LerpValue(this.damperF, (!isGrounded) ? 0f : 1f, 1f, 10f);
				this.heightOffset -= this.grounding.GetVerticalOffset(p, Vector3.zero) * this.grounding.pelvisDamper * this.damperF;
				this.IKOffset = this.grounding.up * this.heightOffset;
			}

			// Token: 0x04000298 RID: 664
			private Grounding grounding;

			// Token: 0x04000299 RID: 665
			private Vector3 lastRootPosition;

			// Token: 0x0400029A RID: 666
			private float damperF;

			// Token: 0x0400029B RID: 667
			private bool initiated;

			// Token: 0x0400029C RID: 668
			private float lastTime;
		}
	}
}
